package ProcessManager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class ProcessServerSocket {
	public static void main(String args[]) throws IOException{
		try{
			ServerSocket ss=new ServerSocket(9999);
			Socket sk=ss.accept();
			System.out.println("server:connected"+sk);
			PrintStream sout = System.out;
			BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
			BufferedReader is = new BufferedReader(new InputStreamReader(sk.getInputStream()));
			PrintWriter os = new PrintWriter(sk.getOutputStream());
			
			String readline=is.readLine();
			while(!readline.equals("bye")){
				os.println(sin.readLine());
				os.flush();
				sout.flush();
				readline=is.readLine();
			}
			os.close();
			is.close();
			sk.close();
		}catch (Exception e) {
			e.printStackTrace();
		}

	}
}
